home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / cvs-1.8 / cvs-1 / cvs-1.8.1 / src / log.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-06  |  3.7 KB  |  164 lines

  1. /*
  2.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  3.  * Copyright (c) 1989-1992, Brian Berliner
  4.  * 
  5.  * You may distribute under the terms of the GNU General Public License as
  6.  * specified in the README file that comes with the CVS 1.4 kit.
  7.  * 
  8.  * Print Log Information
  9.  * 
  10.  * This line exists solely to test some pcl-cvs/ChangeLog stuff.  You
  11.  * can delete it, if indeed it's still here when you read it.  -Karl
  12.  *
  13.  * Prints the RCS "log" (rlog) information for the specified files.  With no
  14.  * argument, prints the log information for all the files in the directory
  15.  * (recursive by default).
  16.  */
  17.  
  18. #include "cvs.h"
  19.  
  20. static Dtype log_dirproc PROTO((char *dir, char *repository, char *update_dir));
  21. static int log_fileproc PROTO((struct file_info *finfo));
  22.  
  23. static const char *const log_usage[] =
  24. {
  25.     "Usage: %s %s [-l] [rlog-options] [files...]\n",
  26.     "\t-l\tLocal directory only, no recursion.\n",
  27.     NULL
  28. };
  29.  
  30. static int ac;
  31. static char **av;
  32.  
  33. int
  34. cvslog (argc, argv)
  35.     int argc;
  36.     char **argv;
  37. {
  38.     int i;
  39.     int err = 0;
  40.     int local = 0;
  41.  
  42.     if (argc == -1)
  43.     usage (log_usage);
  44.  
  45.     /*
  46.      * All 'log' command options except -l are passed directly on to 'rlog'
  47.      */
  48.     for (i = 1; i < argc && argv[i][0] == '-'; i++)
  49.       if (argv[i][1] == 'l')
  50.     local = 1;
  51.  
  52.     wrap_setup ();
  53.  
  54. #ifdef CLIENT_SUPPORT
  55.     if (client_active) {
  56.     /* We're the local client.  Fire up the remote server.  */
  57.     start_server ();
  58.     
  59.     ign_setup ();
  60.  
  61.     for (i = 1; i < argc && argv[i][0] == '-'; i++)
  62.       send_arg (argv[i]);
  63.  
  64.     send_file_names (argc - i, argv + i, SEND_EXPAND_WILD);
  65. /* FIXME:  We shouldn't have to send current files to get log entries, but it
  66.    doesn't work yet and I haven't debugged it.  So send the files --
  67.    it's slower but it works.  gnu@cygnus.com  Apr94  */
  68.     send_files (argc - i, argv + i, local, 0);
  69.  
  70.     send_to_server ("log\012", 0);
  71.         err = get_responses_and_close ();
  72.     return err;
  73.     }
  74.  
  75.     ac = argc;
  76.     av = argv;
  77. #endif
  78.  
  79.     err = start_recursion (log_fileproc, (FILESDONEPROC) NULL, log_dirproc,
  80.                (DIRLEAVEPROC) NULL, argc - i, argv + i, local,
  81.                W_LOCAL | W_REPOS | W_ATTIC, 0, 1,
  82.                (char *) NULL, 1, 0);
  83.     return (err);
  84. }
  85.  
  86.  
  87. /*
  88.  * Do an rlog on a file
  89.  */
  90. /* ARGSUSED */
  91. static int
  92. log_fileproc (finfo)
  93.     struct file_info *finfo;
  94. {
  95.     Node *p;
  96.     RCSNode *rcsfile;
  97.     int retcode = 0;
  98.  
  99.     if ((rcsfile = finfo->rcs) == NULL)
  100.     {
  101.     /* no rcs file.  What *do* we know about this file? */
  102.     p = findnode (finfo->entries, finfo->file);
  103.     if (p != NULL)
  104.     {
  105.         Entnode *e;
  106.         
  107.         e = (Entnode *) p->data;
  108.         if (e->version[0] == '0' || e->version[1] == '\0')
  109.         {
  110.         if (!really_quiet)
  111.             error (0, 0, "%s has been added, but not committed",
  112.                finfo->file);
  113.         return(0);
  114.         }
  115.     }
  116.     
  117.     if (!really_quiet)
  118.         error (0, 0, "nothing known about %s", finfo->file);
  119.     
  120.     return (1);
  121.     }
  122.  
  123.     run_setup ("%s%s -x,v/", Rcsbin, RCS_RLOG);
  124.     {
  125.       int i;
  126.       for (i = 1; i < ac && av[i][0] == '-'; i++)
  127.       if (av[i][1] != 'l')
  128.           run_arg (av[i]);
  129.     }
  130.     run_arg (rcsfile->path);
  131.  
  132.     if (*finfo->update_dir)
  133.     {
  134.       char *workfile = xmalloc (strlen (finfo->update_dir) + strlen (finfo->file) + 2);
  135.       sprintf (workfile, "%s/%s", finfo->update_dir, finfo->file);
  136.       run_arg (workfile);
  137.       free (workfile);
  138.     }
  139.  
  140.     if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_REALLY)) == -1)
  141.     {
  142.     error (1, errno, "fork failed for rlog on %s", finfo->file);
  143.     }
  144.     return (retcode);
  145. }
  146.  
  147. /*
  148.  * Print a warm fuzzy message
  149.  */
  150. /* ARGSUSED */
  151. static Dtype
  152. log_dirproc (dir, repository, update_dir)
  153.     char *dir;
  154.     char *repository;
  155.     char *update_dir;
  156. {
  157.     if (!isdir (dir))
  158.     return (R_SKIP_ALL);
  159.  
  160.     if (!quiet)
  161.     error (0, 0, "Logging %s", update_dir);
  162.     return (R_PROCESS);
  163. }
  164.